package joc.customize;

import java.lang.annotation.Annotation;
import java.lang.reflect.ParameterizedType;


public abstract class Contract<T extends Annotation> {
	@SuppressWarnings("unchecked")
	public Class<T> getAnnotationClass() {
		return (Class<T>) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0];
	}

	protected PartialEvaluationResult getFailure(String errorMessage) {
		return new PartialEvaluationResult(getAnnotationClass(), false, errorMessage);
	}

	protected PartialEvaluationResult getSuccess() {
		return new PartialEvaluationResult(getAnnotationClass(), true, "");
	}

	protected PartialEvaluationResult getResult(boolean success, String errorMessage) {
		return new PartialEvaluationResult(getAnnotationClass(), success, errorMessage);
	}
}
